<template>
  <div class="action-btn-wp">
    <el-button type="primary" size="small" @click.stop.prevent="handelClick()" :loading="submiting">确认收货并换货</el-button>

    <action-deliver ref="ad" :scope="scopeCopy" :showBtn="false" :service="true" @deliver-success="deliverSuccess"></action-deliver>

  </div>
</template>

<script>
  import actionDeliver from '../../order/components/actionDeliver.vue';
  import {confirmOrderReceive} from '@/api/order';
  import {showMessage} from '@/utils/message';

  export default {
    name: 'actionChangeReceived', /*确认收货并换货*/
    components:
    {
      'action-deliver':actionDeliver,
    },
    props:{
      scope:{
        type:Object,
        default:()=>{},
      },
      scopeId:{
        type:String,
        default:'id'
      },
    },
    data(){
      return {
        submiting:false,
      }
    },
    computed:{
      scopeCopy()
      {
        return this.scope;
      }
    },
    methods: {
      handelClick()
      {
        let index = this.scope.index,
            row =  this.scope.row,
            rows = this.scope.rows;
        let id = row[this.scopeId];

        this.$confirm('确认收货后您可对商品进行完整性检查。', '确认收货并换货？', {
          confirmButtonText: '确认收货并换货',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {

          this.$refs['ad'].deliver();

          //this.submiting = true;

        }).catch(() => {

        });

      },
      deliverSuccess()
      {
        this.$emit('success');
      }
    }
  }
</script>